
<%@ page import="com.pijunn.label.LabeledItem" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'lostEvents.label', default: 'Lost Reports')}" />
		<title><g:message code="lostEvents.list.label" default="Your Lost Reports" /></title>
	</head>
	<body>
		<a href="#list-labeledItem" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div class="nav" role="navigation">
			<ul>
				<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
			</ul>
		</div>
		<div id="list-labeledItem" class="content scaffold-list" role="main">
			<h1><g:message code="lost.list.action.label" default="Select the Lost Item" /></h1>
			<g:if test="${flash.message}">
				<div class="message" role="status">${flash.message}</div>
			</g:if>
			<g:form action="report" method="post">
				<g:hasErrors bean="${cmd}">
					<ul class="errors" role="alert">
						<g:eachError bean="${lostItemInstanceList}" var="error">
						<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
						</g:eachError>
					</ul>
				</g:hasErrors>
				<table>
					<thead>
						<tr>
							<th></th>
							
							<g:sortableColumn property="description" title="${message(code: 'labeledItem.description.label', default: 'Description')}" />
						
							<g:sortableColumn property="lostTime" title="${message(code: 'labeledItem.lostTime.label', default: 'Time Lost')}" />
						
							<g:sortableColumn property="location" title="${message(code: 'labeledItem.location.label', default: 'Location')}" />
						
							<g:sortableColumn property="venue" title="${message(code: 'labeledItem.venue.label', default: 'Venue')}" />
						
						</tr>
					</thead>
					<tbody>
					<g:each in="${lostItemInstanceList}" status="i" var="lostItemInstance">
						<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
							<td><g:link action="delete" params="${[id: lostItemInstance.id]}" class="button">I Found It</g:link></td>
							
							<td><g:link action="report" params="${[eventId: lostItemInstance.id, itemId: lostItemInstance.item.id, wizardStep:'select']}" class="desc">${fieldValue(bean: lostItemInstance, field: "description")}</g:link></td>
								
							<td>${fieldValue(bean: lostItemInstance, field: "lostTime")}</td>
								
							<td><ul><g:each in="${lostItemInstance.track}" var="track">
								<li>${track.location}
							</g:each></ul></td>
								
							<td><ul><g:each in="${lostItemInstance.track}" var="track">
								<li>${track.venue }</li>
							</g:each></td>
						</tr>
					</g:each>
					</tbody>
				</table>
				<div class="pagination">
					<g:paginate total="${lostItemInstanceList.size()}" />
				</div>
			</g:form>
		</div>
	<script type="text/javascript">
	<!--
	$(document).ready(function(){
		
		$('.button').button()
		 .click(function( event ) {
			var els = $(this).parentsUntil('tbody');
			var row = els[els.length - 1];
			return confirm('Are you sure you want to delete the report for: ' + $('.desc', row).text());
		 });
	});
	-->
	</script>
	</body>
</html>
